---
title: 评论
icon: MessageSquareMore
---

import { IconWrapper } from '@/components/icon-wrapper'

<MetaData
  lang="zh-CN"
  meta={{
    preset: [{
      client: '@univerjs/preset-docs-thread-comment',
      locale: '@univerjs/preset-docs-thread-comment/locales/zh-CN',
      style: '@univerjs/preset-docs-thread-comment/lib/index.css',
    }],
    plugins: [{
      client: '@univerjs/thread-comment',
    }, {
      client: '@univerjs/thread-comment-ui',
      locale: '@univerjs/thread-comment-ui/locale/zh-CN',
      style: '@univerjs/thread-comment-ui/lib/index.css',
    }, {
      client: '@univerjs/docs-thread-comment-ui',
      style: '@univerjs/docs-thread-comment-ui/lib/index.css',
    }],
    server: '可选',
  }}
/>

评论功能允许用户在文档中添加评论和回复，便于团队成员之间的交流和协作。

## 预设模式

### 安装

```package-install
npm install @univerjs/preset-docs-thread-comment
```

### 使用

```typescript
import { UniverDocsCorePreset } from '@univerjs/preset-docs-core'
import UniverPresetDocsCoreZhCN from '@univerjs/preset-docs-core/locales/zh-CN'
import { UniverDocsThreadCommentPreset } from '@univerjs/preset-docs-thread-comment' // [!code ++]
import UniverPresetDocsThreadCommentZhCN from '@univerjs/preset-docs-thread-comment/locales/zh-CN' // [!code ++]
import { createUniver, LocaleType, mergeLocales } from '@univerjs/presets'

import '@univerjs/preset-docs-core/lib/index.css'
import '@univerjs/preset-docs-thread-comment/lib/index.css' // [!code ++]

const { univerAPI } = createUniver({
  locale: LocaleType.ZH_CN,
  locales: {
    [LocaleType.ZH_CN]: mergeLocales(
      UniverPresetDocsCoreZhCN,
      UniverPresetDocsThreadCommentZhCN, // [!code ++]
    ),
  },
  presets: [
    UniverDocsCorePreset(),
    UniverDocsThreadCommentPreset(), // [!code ++]
  ],
})
```

#### 配合协同编辑使用 <IconWrapper className="inline-flex" type="pro" size="xs" icon={null} />

如需配合 `UniverDocsCollaborationPreset` 使用[协同编辑](/guides/docs/features/collaboration)功能，请确保在 `UniverDocsThreadCommentPreset` 中传入 `collaboration: true` 选项。

```typescript
UniverDocsThreadCommentPreset({
  collaboration: true, // [!code ++]
})
```

{/* ### 预设与配置 */}

## 插件模式

### 安装

```package-install
npm install @univerjs/thread-comment @univerjs/thread-comment-ui @univerjs/docs-thread-comment-ui
```

### 使用

```typescript
import { LocaleType, mergeLocales, Univer } from '@univerjs/core'
import { UniverDocsThreadCommentUIPlugin } from '@univerjs/docs-thread-comment-ui' // [!code ++]
import { UniverThreadCommentPlugin } from '@univerjs/thread-comment' // [!code ++]
import { UniverThreadCommentUIPlugin } from '@univerjs/thread-comment-ui' // [!code ++]
import ThreadCommentUIZhCN from '@univerjs/thread-comment-ui/locale/zh-CN' // [!code ++]

import '@univerjs/thread-comment-ui/lib/index.css' // [!code ++]

const univer = new Univer({
  locale: LocaleType.ZH_CN,
  locales: {
    [LocaleType.ZH_CN]: mergeLocales(
      ThreadCommentUIZhCN, // [!code ++]
    ),
  },
})

univer.registerPlugin(UniverThreadCommentPlugin) // [!code ++]
univer.registerPlugin(UniverThreadCommentUIPlugin) // [!code ++]
univer.registerPlugin(UniverDocsThreadCommentUIPlugin) // [!code ++]
```

#### 配合协同编辑使用 <IconWrapper className="inline-flex" type="pro" size="xs" icon={null} />

如使用[协同编辑](/guides/docs/features/collaboration)功能，需参照以下方式配置：

```package-install
npm install @univerjs-pro/thread-comment-datasource
```

```typescript
import { UniverThreadCommentDataSourcePlugin } from '@univerjs-pro/thread-comment-datasource' // [!code ++]

univer.registerPlugin(UniverThreadCommentDataSourcePlugin) // [!code ++]
```

{/* ### 插件与配置 */}
